home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
database
/
dg53.zip
/
SAMPLES.DAT
< prev
next >
Wrap
Text File
|
1997-06-07
|
98KB
|
1,931 lines
rem do example 0
@echo off
cls
if %1PP == PP goto hlp
if %1 == all goto dem1
if %1 == dem1 goto dem1
if %1 == dem2 goto dem2
if %1 == dem3 goto dem3
if %1 == dem4 goto dem4
if %1 == dem5 goto dem5
if %1 == dem6 goto dem6
if %1 == list goto list
echo ######## Invalid argument
goto hlp
rem
*
text example 1
+------------------------------------------------------------------------+
| |
| +----------------+ |
| | DG DEMO INTRO | |
| +----------------+ |
| |
| The examples given here are not all inclusive, but should |
| give you a feel for dg. |
| |
| Most folks will get all they need from dem1 through dem4. |
| The remainder address less commonly needed capabilities. |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 1
:dem1
@echo off
cls
dg -ekp "text example 1" samples.dat
pause
*
text example 2
+------------------------------------------------------------------------+
| |
| +----------------+ |
| | DG DEMO PART 1 | |
| +----------------+ |
| -- simple searches |
| -- case sensitive searches (-C) |
| -- inverted sense: records that DON'T have the phrase (-v) |
| -- phrases with spaces need to be quoted |
| -- considering phrases that crossover the end of a line (-x) |
| -- "highlighting" why the record was a hit (-H) |
| -- just a bit about secondary delimiters (-h) |
| -- using the GREP mode (-G) |
| -- getting a record count for a file (status) (-s) |
| -- searching multiple files with the dgw batch file (dgw) |
| |
+------------------------------------------------------------------------+
*
rem do example 2
@echo off
cls
dg -ekp "text example 2" samples.dat
pause
*
text example 3
+------------------------------------------------------------------------+
| |
| lincoln.sam is a SAMple file containing a small set of excerpts from |
| Lincoln's speeches. The "records" are separated by "*" delimiters. |
| Later, in dem4, we'll look at paragraph mode-- a mode for files |
| that have no "*" delimiters. |
| |
| Right now, let's look for the famous quotation mentioning malice. |
| We can use the dg command with no arguments at all: |
| |
| dg malice lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 3
@echo off
cls
dg -ekp "text example 3" samples.dat
pause
dg malice lincoln.sam
echo ######## ====================================================
echo ######## That was pretty simple: the record was separated by
echo ######## asterisk delimiters. There was only one record
echo ######## containing the word malice.
echo ######## ====================================================
pause
*
text example 4
+------------------------------------------------------------------------+
| |
| Let's look this time for references to "God" in the lincoln sample |
| file. I'll capitalize the search term to show that the default |
| search is case-insensitive. |
| |
| dg GOD lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 4
@echo off
cls
dg -ekp "text example 4" samples.dat
pause
dg GOD lincoln.sam
echo ######## ====================================================
echo ######## This time there were 2 matching records.
echo ######## ====================================================
pause
*
text example 5
+------------------------------------------------------------------------+
| |
| Let's do the same thing, but use the -C option, forcing a case |
| sensitive search. |
| |
| dg -C GOD lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 5
@echo off
cls
dg -ekp "text example 5" samples.dat
pause
dg -C GOD lincoln.sam
echo ######## ====================================================
echo ######## This time there is only 1 matching record.
echo ######## ====================================================
pause
*
text example 6
+------------------------------------------------------------------------+
| |
| Inverted sense: |
| |
| We can also find records that do NOT have a reference to "God". |
| The -v "invert sense" option works with most, but not all, other |
| options. You'll get an error message if you use -v with an |
| incompatible option. |
| |
| dg -v GOD lincoln.sam |
| |
| (In a real mode, we'd use "dg -v GOD lincoln.sam > catchfil" |
| since we know the results will overflow the screen. |
| Then the file catchfil would hold our results. ) |
| |
+------------------------------------------------------------------------+
*
rem do example 6
@echo off
cls
dg -ekp "text example 6" samples.dat
pause
dg -v GOD lincoln.sam
echo ######## ====================================================
echo ######## This time we printed the 11 example records
echo ######## that do NOT have the name GOD.
echo ######## If the command had used redirection to a file,
echo ######## that file would now hold the 11 finds in a form
echo ######## ready for more dg work, as desired.
echo ######## ====================================================
pause
*
text example 7
+------------------------------------------------------------------------+
| |
| If we were looking for a phrase, we'd need to put the phrase in |
| quotes (double quotes for DOS, single for UNIX): |
| |
| dg "same God" lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 7
@echo off
cls
dg -ekp "text example 7" samples.dat
pause
dg "same God" lincoln.sam
echo ######## ====================================================
echo ######## This was a pretty simple phrase search.
echo ######## But phrases in text may cross over a line break.
echo ######## The search command, as written, would not have found:
echo ######## .....................................the same
echo ######## God ...................................
echo ######## ====================================================
pause
*
text example 8
+------------------------------------------------------------------------+
| |
| Let's try looking for a longer phrase: |
| |
| dg "finish the work we are in" lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 8
@echo off
cls
dg -ekp "text example 8" samples.dat
pause
dg "finish the work we are in" lincoln.sam
echo ######## ====================================================
echo ######## No finds. The phrase was not found on any one line.
echo ######## See the next example.
echo ######## ====================================================
pause
*
text example 9
+------------------------------------------------------------------------+
| |
| Let's try looking for that longer phrase using the -x "crossover" |
| option: |
| |
| dg -x "finish the work we are in" lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 9
@echo off
cls
dg -ekp "text example 9" samples.dat
pause
dg -x "finish the work we are in" lincoln.sam
echo ######## ====================================================
echo ######## This time we find the phrase.
echo ######## The -x option will only cross over (xover) one line
echo ######## break. It is best when used with the -T option
echo ######## i.e. dg -xT
echo ######## This will ensure that any excess spaces at the end
echo ######## or start of a line are ignored.
echo ######## ====================================================
pause
*
text example 10
+------------------------------------------------------------------------+
| |
| Sometimes the records we find will be relatively large, and it may |
| not be easy to spot why the record was a "hit." |
| |
| We can use the -H "highlight" option to help spot it, and pipe the |
| result to the DOS "more" program to halt the output at each |
| screenful: |
| |
| dg -H wrong lincoln.sam | more |
| |
+------------------------------------------------------------------------+
*
rem do example 10
@echo off
cls
dg -ekp "text example 10" samples.dat
pause
dg -H wrong lincoln.sam | more
echo ######## ====================================================
echo ######## Note that only the first hit in each record is
echo ######## highlighted, and always at the beginning of the line.
echo ######## ====================================================
pause
*
text example 11
+------------------------------------------------------------------------+
| |
| Note that in the example lincoln text, records contain many |
| paragraphs in a single record (records separated by asterisks). |
| |
| If each "record" contained many paragraphs, we might like to |
| "subdivide" the record, getting only the paragraphs of interest. |
| |
| The -h option allows designating a secondary delimiter inside the |
| main records. Use -h alone (as the LAST option) or -hh (with other |
| options) and a blank line will be considered the secondary delimiter. |
| |
| For example: |
| |
| dg -h wrong lincoln.sam | more |
| |
+------------------------------------------------------------------------+
*
rem do example 11
@echo off
cls
dg -ekp "text example 11" samples.dat
pause
dg -h wrong lincoln.sam | more
echo ######## ====================================================
echo ######## Note that the first, i.e., key, line of the primary
echo ######## record is printed along with a warning that what
echo ######## follows is a partial record only.
echo ######## ====================================================
pause
*
text example 12
+------------------------------------------------------------------------+
| |
| The -G option makes dg behave like grep rather than dg. Record |
| delimiters are ignored, and only lines with the defined searchterm |
| are shown. Use it only if you don't have the real grep program, |
| as the latter has more power, especially in the use of regular |
| expressions. Note: a real grep defaults to case-sensitive, while |
| dg will default to case-insensitive. |
| |
| For example: |
| |
| dg -G god lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 12
@echo off
cls
dg -ekp "text example 12" samples.dat
pause
dg -G god lincoln.sam
echo ######## ====================================================
echo ######## Just the lines are shown, with no indication of
echo ######## which records they are from.
echo ######## .
echo ######## The -G option should work well along with
echo ######## the following options: wucCvTefNFm and ^$ usage,
echo ######## but a real grep is preferable.
echo ######## ====================================================
pause
*
text example 13
+------------------------------------------------------------------------+
| |
| Before we leave the example lincoln text, lets try the -s status |
| option. |
| |
| The -s option alone reports only the number of records. Use with |
| -V (verbose) to get a bit more information: |
| |
| dg -Vs lincoln.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 13
@echo off
cls
dg -ekp "text example 13" samples.dat
pause
dg -Vs lincoln.sam
echo ######## ====================================================
echo ######## Null record are those with only line endings between
echo ######## successive record delimiters.
echo ######## Null -- mt -- keylines are legal, but unexpected
echo ######## empty lines at the start of a record.
echo ######## ====================================================
pause
*
text example 14
+------------------------------------------------------------------------+
| |
| One final set of examples-- how to use dg to search across |
| multiple files. dg, by itself, will not recognize wildcards in |
| the filename on the command line. Use the dgw batch file when |
| you want dg to search across multiple files. We'll run the |
| following: |
| |
| dgw -o politics *.sam |
| |
| to look for the term "politics" in all the sample files. When |
| using the batch file, dg arguments may be included. At least |
| one MUST be included. The -o argument is a "do-nothing" argument |
| that acts as a placeholder. |
| |
+------------------------------------------------------------------------+
*
rem do example 14
@echo off
cls
dg -ekp "text example 14" samples.dat
pause
call dgw -o politics *.sam
echo ######## ====================================================
echo ######## Two records were found. Each happens to come from
echo ######## a different sample file. Results are always
echo ######## redirected to a temporary file called ztempx.
echo ######## Change the batch file if you want other behavior.
echo ######## ====================================================
pause
*
text example 15
+------------------------------------------------------------------------+
| |
| If you want the output to show which searched files contained the |
| hits, use the -qV option combination: |
| |
| dgw -qV politics *.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 15
@echo off
cls
dg -ekp "text example 15" samples.dat
pause
call dgw -qV politics *.sam
echo ######## ====================================================
echo ######## If you've written the output to, say, tempfile,
echo ######## you may, after inspecting the results, purge
echo ######## the advisories with:
echo ######## dg -v "Searching file:" tempfile
echo ######## ====================================================
pause
*
text example 16
+------------------------------------------------------------------------+
| |
| Note that the dgw results are always written to a file named ztempx, |
| in the current working directory. |
| |
| The batch file will complain if you try to search ALL (*.* or *) |
| files in the current working directory since that would include |
| the output ztempx file. |
| |
| If you must search ALL files in a directory (* or *.*), do so from |
| a higher level directory. dgw -o srchterm asubdir/*.* |
| will work fine. |
| |
| Here's an example of the kind of complaint you'll get if you |
| forget: |
| |
| dgw -o politics *.* |
| |
+------------------------------------------------------------------------+
*
rem do example 16
@echo off
cls
dg -ekp "text example 16" samples.dat
pause
call dgw -o politics *.*
echo ######## ====================================================
echo ######## If you use UNIX and convert the DOS batch to a script,
echo ######## a few well-placed else's will do what the meager
echo ######## DOS language cannot.
echo ######## ====================================================
pause
if %1 == dem1 goto end
*
text example 17
+------------------------------------------------------------------------+
| |
| +----------------+ |
| | DG DEMO PART 2 | |
| +----------------+ |
| |
| -- strings vs. words |
| -- limiting searches to words (-w) |
| -- limiting searches to strings/words |
| at the beginning or end of lines ( ^ $ ) |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 17
@echo off
:dem2
cls
dg -ekp "text example 17" samples.dat
pause
*
text example 18
+------------------------------------------------------------------------+
| |
| A "string" is a chain of characters. "rat" is a string three |
| characters long. Looking for the string "rat" will find the word |
| "rat", and the word "rather". |
| |
| The dg program does not implement full "regular expressions" as |
| that term is used in UNIX. |
| |
| It does support the unix conventions "^" and "$" to designate |
| strings at beginning and end of lines. It also supports a -w option |
| to limit finds to "words" so that a -w search for "rat" will not turn |
| up records with "rather". |
| |
| The next few demo's will walk through these options against a very |
| contrived sample "inventory" file. |
| |
| First lets do the straightforward phrase search: |
| |
| dg rat inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 18
cls
dg -ekp "text example 18" samples.dat | more
pause
cls
dg rat inventry.sam
echo ######## ====================================================
echo ######## The result found all records with "rat"
echo ######## including some we might not have wanted.
echo ######## ====================================================
pause
*
text example 19
+------------------------------------------------------------------------+
| |
| Now lets find records with lines that BEGIN with the string "rat": |
| |
| dg ^rat inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 19
cls
dg -ekp "text example 19" samples.dat | more
echo ######## .
echo ######## .
pause
cls
dg ^rat inventry.sam
echo ######## ====================================================
echo ######## The result shows only records having lines
echo ######## that begin with "rat".
echo ######## ====================================================
pause
*
text example 20
+------------------------------------------------------------------------+
| |
| Now records with lines that END with the string "rat": |
| |
| dg rat$ inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 20
cls
dg -ekp "text example 20" samples.dat | more
echo ######## .
echo ######## .
pause
cls
dg rat$ inventry.sam
echo ######## ====================================================
echo ######## The result shows only records having lines
echo ######## that end with "rat".
echo ######## ====================================================
pause
*
text example 21
+------------------------------------------------------------------------+
| |
| Now records with lines that BEGIN and END with the string "rat": |
| |
| dg ^rat$ inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 21
cls
dg -ekp "text example 21" samples.dat | more
echo ######## .
echo ######## .
pause
cls
dg ^rat$ inventry.sam
echo ######## ====================================================
echo ######## The result shows only records having lines
echo ######## that begin AND end with "rat".
echo ######## .
echo ######## Note that this is NOT quite standard UNIX usage.
echo ######## The ^$ will not limit finds to lines having only
echo ######## the exact enclosed string and nothing more.
echo ######## Use the -e (exact line match) to do that.
echo ######## .
echo ######## The example ^rat$ search literally finds records
echo ######## that begin and end with the string, which may
echo ######## or may not be what you want.
echo ######## ====================================================
pause
*
text example 22
+------------------------------------------------------------------------+
| |
| Use the -w option to limit finds to "rat" as a word. |
| |
| dg -w rat inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 22
cls
dg -ekp "text example 22" samples.dat | more
echo ######## .
echo ######## .
pause
cls
dg -w rat inventry.sam
echo ######## ====================================================
echo ######## The result shows only records having lines
echo ######## that with the string as a word.
echo ######## ====================================================
pause
*
text example 23
+------------------------------------------------------------------------+
| |
| Use the -w option and the ^ to limit finds to "rat" as a word at the |
| beginning of a line. |
| |
| dg -w ^rat inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 23
cls
dg -ekp "text example 23" samples.dat | more
echo ######## .
echo ######## .
pause
cls
dg -w ^rat inventry.sam
echo ######## ====================================================
echo ######## The result shows only records having lines that have
echo ######## the string as a word at the beginning of a line.
echo ######## ====================================================
pause
*
text example 24
+------------------------------------------------------------------------+
| |
| Use the -w option and the $ to limit finds to "rat" as a word at the |
| end of a line. |
| |
| dg -w rat$ inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 24
cls
dg -ekp "text example 24" samples.dat | more
echo ######## .
echo ######## .
pause
cls
dg -w rat$ inventry.sam
echo ######## ====================================================
echo ######## The result shows only records having lines that
echo ######## have the string as a word at the end of a line.
echo ######## ====================================================
pause
*
text example 25
+------------------------------------------------------------------------+
| |
| In the unlikely event that you want to find a string that actually |
| starts with the character "^" or ends with "$", use a backslash ("\") |
| in the search string: |
| |
| dg "\^rat" inventry.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 25
cls
dg -ekp "text example 25" samples.dat | more
echo ######## .
echo ######## .
pause
cls
dg "\^rat" inventry.sam
echo ######## ====================================================
echo ######## The result shows only records having lines
echo ######## that with a literal ^rat string.
echo ######## Usage for a rat$ string would be similar.
echo ######## .
echo ######## Note: Unlike standard UNIX, this usage of
echo ######## the \ term is limited to the ^ and $ literals.
echo ######## ====================================================
pause
if %1 == dem2 goto end
*
text example 26
+------------------------------------------------------------------------+
| |
| +----------------+ |
| | DG DEMO PART 3 | |
| +----------------+ |
| |
| -- using keylines |
| ---- limiting search to keylines (-k) |
| ---- limiting output to keylines (-K) |
| |
| -- multiple string searches |
| ---- multiple terms on a line (-m) |
| ---- multiple terms anywhere in a record (-M) |
| |
| -- using a file of searchterms (-f) |
| |
| -- getting keyline output plus selected (-y) |
| other lines from a record. |
| |
| -- sending each record "hit" to a separate file (-D) |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 26
:dem3
@echo off
cls
dg -ekp "text example 26" samples.dat
pause
*
text example 27
+------------------------------------------------------------------------+
| |
| Free form files with useful keylines: |
| |
| The file minerals.sam is an example of a free form set of reference |
| or study notes. Each record gives a generally unstructured glob of |
| information about a particular mineral. |
| |
| The KEY (first) line, however, does have a little structure, giving a |
| primary mineral name, possibly some alternate names, a fluorescence |
| flag (FLFL) where appropriate, a general type (oxide, sulfide, etc.), |
| and the chemical formula. |
| |
| For example: |
| |
| axinite FLFLRED+ //borosilicate Ca2(Mn,Fe)Al2BSi4O15(OH)|
| |
| The file provides one example of how keyline searches (-k) can be put |
| to good use. |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 27
cls
dg -ekp "text example 27" samples.dat
pause
*
text example 28
+------------------------------------------------------------------------+
| |
| For example, lets try this case-sensitive search (-C) for iron (Fe) |
| minerals without using the -k option. (We'll throw in the -V verbose |
| option to show what that does as well.) |
| |
| dg -VC Fe minerals.sam | more |
| |
| Note that many records will NOT have an Fe in the keyline, which |
| means they are not REALLY what we are looking for. |
| |
+------------------------------------------------------------------------+
*
rem do example 28
cls
dg -ekp "text example 28" samples.dat
pause
dg -VC Fe minerals.sam | more
echo ######## ====================================================
echo ######## Naturally we got more than we wanted.
echo ######## .... Many records about non-Fe minerals,
echo ######## that happened to mention Fe somewhere in the record.
echo ######## ====================================================
pause
*
text example 29
+------------------------------------------------------------------------+
| |
| Now try the search with -k to limit searching to the 1st keyline |
| only. |
| |
| dg -VCk Fe minerals.sam | more |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 29
cls
dg -ekp "text example 29" samples.dat
pause
dg -VCk Fe minerals.sam | more
echo ######## ====================================================
echo ######## This is what we wanted.
echo ######## ====================================================
pause
*
text example 30
+------------------------------------------------------------------------+
| |
| We could do the same search, adding a -K3 option. Altogether, this |
| would mean: search only the first keyline (-k) but show only the |
| first 3 (key)lines of each record: |
| |
| dg -VCkK3 Fe minerals.sam | more |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 30
cls
dg -ekp "text example 30" samples.dat
pause
dg -VCkK3 Fe minerals.sam | more
echo ######## ====================================================
echo ######## The value of the -k and -K options depends entirely
echo ######## on whether you want to design your record-keeping to
echo ######## take advantage of these features.
echo ######## .
echo ######## If your file structure has the most needed info in
echo ######## the first few lines, this option is especially
echo ######## useful for quickie summaries.
echo ######## ====================================================
pause
*
text example 31
+------------------------------------------------------------------------+
| |
| As an aside, you may have noted that the verbose option we've been |
| using provides a count of hits. To get *only* a count of hits, use |
| the -c option instead: |
| |
| dg -cC Fe minerals.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 31
cls
dg -ekp "text example 31" samples.dat
pause
dg -cC Fe minerals.sam
echo ######## ====================================================
echo ######## Just a count of how many records were hits.
echo ######## ====================================================
pause
*
text example 32
+------------------------------------------------------------------------+
| |
| Searching for multiple terms on a line: |
| |
| Suppose we wanted to find minerals with keylines having 2 desired |
| terms "Fe" and "sulfide". We use the -m (multiple) option and TWO |
| searchterms where we normally have only one. |
| |
| dg -Ckm Fe sulfide minerals.sam | more |
| |
+------------------------------------------------------------------------+
*
rem do example 32
cls
dg -ekp "text example 32" samples.dat
pause
dg -Ckm Fe sulfide minerals.sam | more
echo ######## ====================================================
echo ######## The -m multiple option defaults to -m2
echo ######## meaning 2 searchterms on the command line
echo ######## following the options and prior to the filename.
echo ######## ====================================================
pause
*
text example 33
+------------------------------------------------------------------------+
| Now lets try 3 desired terms: Fe and sulfide and As on the keyline: |
| |
| dg -Ckm3 Fe sulfide As minerals.sam |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 33
cls
dg -ekp "text example 33" samples.dat
pause
dg -Ckm3 Fe sulfide As minerals.sam
echo ######## ====================================================
echo ######## The -m3 multiple option expects 3 terms to follow.
echo ######## You get a hit only if all 3 terms are found on one line.
echo ######## ====================================================
pause
*
text example 34
+------------------------------------------------------------------------+
| |
| The -m option looks for multiple searchterms on a single line. |
| |
| Use -M to look for multiple searchterms record-wide. |
| |
| For example, to find records containing the terms "silicate" and |
| "phosphor" somewhere in the record: |
| |
| dg -M silicate phosphor minerals.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 34
cls
dg -ekp "text example 34" samples.dat
pause
dg -M silicate phosphor minerals.sam | more
echo ######## ====================================================
echo ######## There are many applications when this can be
echo ######## very valuable.
echo ######## .
echo ######## As with -m, the -M defaults to 2 terms
echo ######## but -M3 to -M9 are supported.
echo ######## ====================================================
pause
*
text example 35
+------------------------------------------------------------------------+
| |
| The -m and -M options look for multiple terms in the sense of an |
| "AND" sort of search. When we want to do an OR search, the best bet |
| is to use the -f option, putting our searchterms into a file. |
| |
| For example, many of the mineral records have a fluorescence color in |
| the key line. Suppose we wanted a list of minerals that fluoresce |
| red, pink, orange, or yellow. Put those 4 words in a file, e.g., |
| wanted.sam- with one phrase (in this case, one word) per line.. and |
| then: |
| |
| dg -kKpf wanted.sam minerals.sam |
| |
| will deliver the first keyline (-K print 1 keyline only) of all |
| records that match, in the keyline (-k), one of the terms in the |
| searchfile named wanted.sam The -p (plain) option inhibits printing |
| stars on output. |
| |
+------------------------------------------------------------------------+
*
rem do example 35
cls
dg -ekp "text example 35" samples.dat
echo ######## .
echo ######## .
pause
dg -kKpf wanted.sam minerals.sam
echo ######## ====================================================
echo ######## The ability to specify multiple searchterms
echo ######## in a file can be very powerful, and is particularly
echo ######## satisfying if you have somehow convinced some other
echo ######## software to automatically generate the file of terms
echo ######## to search for.
echo ######## ====================================================
pause
*
text example 36
+------------------------------------------------------------------------+
| |
| The -y option looks like a -m multiple terms search, but it is |
| quite different. |
| |
| For example, many of the mineral records have a line starting with "H" |
| for "Hardness" or SG for Specific Gravity. It is often, but not |
| always, the second and/or third line in a record. But its a lazily |
| organized file and we can't depend on that. In any case, suppose we |
| want oxide records, and their Hardness and Specific Gravity data only. |
| The following use of the -y option will do the job. |
| |
| dg -yCkKm3r oxide ^H ^SG minerals.sam |
| |
| This will deliver the first keyline (-K print 1 keyline only) of all |
| records that match, in the keyline (-k), the single term "oxide" and |
| then print any remaining lines in those records that begin with an "H" |
| or an "SG". The -r option gives better visual separation of records. |
| |
+------------------------------------------------------------------------+
*
rem do example 36
cls
dg -ekp "text example 36" samples.dat
echo ######## .
echo ######## .
pause
dg -yCkKm3r oxide ^H ^SG minerals.sam | more
echo ######## ====================================================
echo ######## Note that a -m3 was needed in the options to allow
echo ######## for the 3 multiple search terms, but the -y
echo ######## completely changes how the search terms are
echo ######## interpreted. The first term is now the _sole_ search
echo ######## term for a record hit, and the remaining are
echo ######## used to pick out lines from the rest of the record.
echo ######## .
echo ######## This can be a powerful capability, depending on
echo ######## the nature of your records.
echo ######## .
echo ######## Use it with records that are long, but have good
echo ######## keyword lines and any kind of "tagging" in the
echo ######## rest of the record lines.
echo ######## ====================================================
pause
*
text example 37
+------------------------------------------------------------------------+
| |
| This is a good place to demo the -D option, which outputs |
| (Distributes) each record found to a separate file. This is |
| exceptionally useful when you plan to process each of your |
| finds with another program of some sort. |
| |
| Follow the -D with the desired output file prefix. For DOS, this must |
| be limited to 4 characters or less, and the output limit will be 9999 |
| files (even with a 1-3 character prefix). |
| |
| The command: |
| |
| dg -kfDhots wanted.sam minerals.sam |
| |
| will Deliver the whole record (no -K this time) of all records that |
| match, in the keyline (-k limits search to 1st keyline), one of the |
| terms in the searchfile named wanted.sam-- and place each find in |
| separate file, e.g., hots0001, hots0002, etc. |
| |
| wanted.sam holds the "hot" colors: red, yellow, orange, pink |
| |
+------------------------------------------------------------------------+
*
rem do example 37
cls
dg -ekp "text example 37" samples.dat
pause
dg -kfDhots wanted.sam minerals.sam
echo ######## ====================================================
echo ######## You will appreciate this capability if your goal
echo ######## is to select specific cases from a master file
echo ######## to be submitted to some common test procedure
echo ######## or other processing.
echo ######## .
echo ######## .
echo ######## Lets look at one of the resulting files, hots0007:
echo ######## ====================================================
pause
type hots0007
echo ######## ====================================================
pause
if %1 == dem3 goto end
*
text example 38
+------------------------------------------------------------------------+
| |
| +----------------+ |
| | DG DEMO PART 4 | |
| +----------------+ |
| |
| -- paragraph mode (-dd) |
| ---- keylines in paragraph mode |
| |
| -- using the -F field option (-F) |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 38
:dem4
@echo off
cls
dg -ekp "text example 38" samples.dat
pause
*
text example 39
+------------------------------------------------------------------------+
| |
| Let's try some examples using the file dgops.sam. This file is a |
| cutout of the options section of the dgman file. No stars (*) are |
| in the file, but the file has good separation of data into paragraphs |
| with BLANK LINES as delimiters, so we don't need any stars. We can |
| use "paragraph mode" with the -dd option. |
| |
| The presence of the option letter on the first line of each paragraph |
| is a perfect setup for the keyline search feature. Try the |
| following: |
| |
| |
| To look up help for the -f option: |
| |
| dg -Cddk -f dgops.sam |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 39
cls
dg -ekp "text example 39" samples.dat
pause
dg -Cddk -f dgops.sam
echo ######## ====================================================
echo ######## The result is shown above.
echo ######## The -dd sets paragraph mode... empty lines are
echo ######## delimiters. The -k limits searching to the
echo ######## first keyline. There is no -K option,
echo ######## so the whole record is shown. The -C
echo ######## made sure we got info on the -f option,
echo ######## and not on the -F option.
echo ######## ====================================================
pause
*
text example 40
+------------------------------------------------------------------------+
| Another similar example, looking for info on the -d option: |
| |
| dg -ddk -d dgops.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 40
cls
dg -ekp "text example 40" samples.dat
pause
dg -ddk -d dgops.sam
echo ######## ====================================================
echo ######## The result is shown above.
echo ######## .
echo ######## The -d option can also change the delimiter, e.g.,
echo ######## a search option of -d^ will work with files that
echo ######## use the hat symbol instead of the asterisk.
echo ######## ====================================================
pause
*
text example 41
+------------------------------------------------------------------------+
| Another similar example, but with an important twist: |
| |
| dg -ddk \^\$ dgops.sam | more |
| |
| We're looking for a paragraph that literally has "^$" in the |
| first keyline. |
| |
+------------------------------------------------------------------------+
*
rem do example 41
cls
dg -ekp "text example 41" samples.dat
pause
dg -ddk \^\$ dgops.sam | more
echo ######## ====================================================
echo ######## The twist is that we see several paragraphs, not one.
echo ######## I cheated-- the dgops.sam file has spaces typed on
echo ######## what look like empty lines separating the text above.
pause
echo ######## Paragraph mode breaks on true empty lines-- not on
echo ######## any old lines with whitespace.. BUT - use -ddT to
echo ######## Trim lead/trail spaces and whitespace lines will
echo ######## behave as if they were truly empty.
echo ######## ====================================================
pause
*
text example 42
+------------------------------------------------------------------------+
| |
| Search now for info about the option that addresses highlighting. |
| We use no -k option, so that whole records are searched: |
| |
| dg -dd highlight dgops.sam |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 42
cls
dg -ekp "text example 42" samples.dat
pause
dg -dd highlight dgops.sam
echo ######## ====================================================
echo ######## The result is shown above
echo ######## ====================================================
pause
*
text example 43
+------------------------------------------------------------------------+
| |
| Search again now for info about the option that addresses |
| highlighting. We still use no -k option, so whole records are |
| searched, but add a -K2 option so that we print out only the first 2 |
| lines of a hit: |
| |
| dg -ddK2 highlight dgops.sam |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 43
cls
dg -ekp "text example 43" samples.dat
pause
dg -ddK2 highlight dgops.sam
echo ######## ====================================================
echo ######## The result is shown above.
echo ######## Note the entirely valid case where the displayed
echo ######## result is missing the searchterm. Remember, we
echo ######## searched the whole record, but limited output to
echo ######## the first 2 keylines.
echo ######## ====================================================
pause
*
text example 44
+------------------------------------------------------------------------+
| There's another way to skin the cat with any files that provide key |
| terms at specific "fields" in various lines. In this sense of the |
| word "field", I mean the sense used in awk-- where each term or word |
| in a line, separated from others by whitespace, is a separate |
| field. Thus in a line such as: |
| |
| cats, lions, tigers, leopards, ocelot |
| |
| field 1 is "cats," and field 2 is "lions," etc. |
| |
+------------------------------------------------------------------------+
*
rem do example 44
:testing
cls
dg -ekp "text example 44" samples.dat
pause
*
text example 45
+------------------------------------------------------------------------+
| |
| In the dgman file, and most man files, the major options are |
| described in paragraphs that have the option letter as the first |
| "field" in a line. We can force the search to look for the desired |
| string only in field 1: |
| |
| The search: |
| |
| dg -ddCF1 -c dgops.sam |
| |
| with the dd specifying blank lines as record delimiters, the -C for |
| case-sensitive searching, and the -F1 specifying that we want to |
| search only the first field in all lines. The -c, in this case, is |
| the searchterm. |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 45
:testing
cls
dg -ekp "text example 45" samples.dat
pause
dg -ddCF1 -c dgops.sam
echo ######## ====================================================
echo ######## The F1 search works well here only because we know
echo ######## this file has the dashed option letters in the first
echo ######## field of some line in the record.
echo ######## .
echo ######## Remember that the -F option without a numeric
echo ######## means to limit the search to the LAST field of
echo ######## the lines, regardless of whether that
echo ######## is the first, second, etc.
echo ######## .
echo ######## .
echo ######## The value of this option depends entirely on how
echo ######## your file data is arranged. Remember to use
echo ######## the -L option with -F if you start getting
echo ######## unwarranted complaints. See manual.
echo ######## .
echo ######## .
echo ######## ====================================================
pause
*
text example 46
+------------------------------------------------------------------------+
| |
| By now, you may be getting a little boggle-eyed at the number of |
| possible options. |
| |
| How can you remember them ? |
| |
| Well, I can't. When I need to do a job once, I dig through my own |
| help to figure out what the option codes are. |
| |
| If I'm expecting to do that job again, the command, with its option |
| letters, goes into a batch file or unix alias. |
| |
| Also-- some notes and keywords and the name of the batch file goes |
| into a general help file (a dg-searchable one, of course) so that |
| I can remember what worked. |
| |
+------------------------------------------------------------------------+
*
rem do example 46
cls
dg -ekp "text example 46" samples.dat
pause
if %1 == dem4 goto end
*
text example 47
+------------------------------------------------------------------------+
| |
| +----------------------------------------+ |
| | DG DEMO PART 5 -- ADVANCED USERS ONLY | |
| +----------------------------------------+ |
| |
| -- Getting records by number (-n# -n#,3) |
| |
| -- Getting only the first hit (-Q) |
| |
| -- Records with labeled-lines |
| ---- Appending new labeled-lines (-a, -aj) |
| ---- Appending to keylines (-A, -Aj) |
| ---- Appending record numbers to keylines (-aJ -Aj) |
| |
+------------------------------------------------------------------------+
*
rem do example 47
:dem5
@echo off
cls
dg -ekp "text example 47" samples.dat
pause
*
text example 48
+------------------------------------------------------------------------+
| Now we'll look at how dg can be used with a more structured kind of |
| file. |
| |
| tasks.sam is a sample file containing software trouble reports, |
| perhaps extracted from a database into a working ASCII file. |
| |
| Its design is VERY different from the almost unstructured files we've |
| used as examples up to now. Many lines are "labeled" lines. |
| |
| Let's start by looking only at record 1, and by the way, introduce |
| the -n option. |
| |
| dg -n1 tasks.sam > task1.tem |
| |
| We'll run the command, redirecting the result to a new file, and then |
| type the new file to the screen. |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 48
cls
dg -ekp "text example 48" samples.dat
pause
dg -n1 tasks.sam > task1.tem
type task1.tem
echo ######## ====================================================
echo ######## The result- the first record- is in file task1.tem
echo ######## which has been TYPE'd to the screen above.
echo ######## .
echo ######## Note how this file is designed to have
echo ######## very structured line names for major
echo ######## elements of each record.
echo ######## ====================================================
pause
*
text example 49
+------------------------------------------------------------------------+
| |
| By the way, the -n option can retrieve a series of records. |
| For example, lets look at records 3 to 5 in tasks.sam: |
| |
| dg -n3,5 tasks.sam | more |
| |
+------------------------------------------------------------------------+
*
rem do example 49
@echo off
cls
dg -ekp "text example 49" samples.dat
pause
dg -n3,5 tasks.sam
echo ######## ====================================================
echo ######## The 3rd, 4th and 5th records were printed.
echo ######## ====================================================
pause
*
text example 50
+------------------------------------------------------------------------+
| |
| Notice that for this file structure, there is a unique record name |
| on line 1. If you are wanting to find a record by name, use the |
| -Q "quit-on-1-find" option. That might save a lot of search time |
| in a really large file. With -k as well, search time is minimized. |
| |
| dg -kQ RYKL0.0-0005 tasks.sam |
| |
+------------------------------------------------------------------------+
*
rem do example 50
cls
dg -ekp "text example 50" samples.dat
pause
dg -kQ RYKL0.0-0005 tasks.sam
echo ######## ====================================================
echo ######## Use -Q only if you are sure there will be
echo ######## only one matching record.
echo ######## ====================================================
pause
*
text example 51
+------------------------------------------------------------------------+
| |
| Now, let's create a temporary subfile of all OPEN tasks. |
| |
| Because of this file's structure, we can use the -m (multiples, same |
| line) search, using a LINE NAME as ONE of the terms-- and knowing |
| (because we designed the structure that way) that OPEN items are so |
| marked in the "STATE----:" line. |
| |
| dg -m state-- open tasks.sam > openrecs.tem |
| |
+------------------------------------------------------------------------+
*
rem do example 51
cls
dg -ekp "text example 51" samples.dat
pause
dg -m state-- open tasks.sam > openrecs.tem
type openrecs.tem
echo ######## ====================================================
echo ######## The result is in file openrecs.tem
echo ######## which has been TYPE'd to the screen above.
echo ######## .
echo ######## We now have a temporary subfile of OPEN tasks
echo ######## that we can further process.
echo ######## ====================================================
pause
*
text example 52
+------------------------------------------------------------------------+
| |
| Now further dig into the subfile of open tasks to create a temporary |
| file of all open tasks assigned to an engineer named Gorgon: |
| |
| dg -m assgn_to-- gorgon openrecs.tem > gorgon.tem |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 52
cls
dg -ekp "text example 52" samples.dat
pause
dg -m assgn_to-- gorgon openrecs.tem > gorgon.tem
type gorgon.tem
echo ######## ====================================================
echo ######## The result is in file gorgon.tem
echo ######## which has been TYPE'd to the screen above.
echo ######## With an appropriate batch file, we could
echo ######## easily create separate listings of each engineer's
echo ######## open tasks.
echo ######## ====================================================
pause
*
text example 53
+------------------------------------------------------------------------+
| The -K option can be very useful with this kind of file. To get |
| a quick on-screen summary of task numbers and titles for any trouble |
| reports mentioning whales: |
| |
| dg -K2 whal tasks.sam |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 53
cls
dg -ekp "text example 53" samples.dat
pause
dg -K2 whal tasks.sam
echo ######## ====================================================
echo ######## The result is shown above
echo ######## ====================================================
pause
*
text example 54
+------------------------------------------------------------------------+
| |
| For a quick list of all tasks, without the star separators: |
| |
| dg -Kpl tasks.sam |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 54
cls
dg -ekp "text example 54" samples.dat
pause
dg -Kpl tasks.sam
echo ######## ====================================================
echo ######## The result is shown above.
echo ######## .
echo ######## I find the -Kpl option combination is one I use
echo ######## frequently on certain kinds of files to review
echo ######## the contents.
echo ######## ====================================================
pause
*
text example 55
+------------------------------------------------------------------------+
| |
| Expanding a structured file: |
| |
| This is a good place to demo one way to use the -a append option. |
| |
| With a file of the sort that has labeled lines, we may want to |
| augment part or all of the file with a new line type. |
| |
| Suppose, for example, we wanted to add a line for the planned |
| completion date. |
| |
| Create a file called "zzapfile" and enter the desired text on a |
| single line. ("zzapfile" is a hardcoded filename with special meaning |
| to dg) |
| |
| This tutorial batch file will do that for you with the command: |
| |
| echo FINISH_DATE-: TBD > zzapfile |
+------------------------------------------------------------------------+
*
rem do example 55
cls
dg -ekp "text example 55" samples.dat
echo ######## .
echo ######## .
pause
*
text example 56
+------------------------------------------------------------------------+
| |
| Once zzapfile has been created, we use: |
| |
| dg -al tasks.sam > taskplus.tem |
| |
| Note that NO searchterm is given, but the -l option is provided. This |
| means to do the append for aLL records, so we can get away without |
| having to specify some searchterm common to all records. |
| |
+------------------------------------------------------------------------+
*
rem do example 56
cls
dg -ekp "text example 56" samples.dat
echo ######## .
echo ######## .
pause
echo FINISH_DATE-: TBD > zzapfile
dg -al tasks.sam > taskplus.tem
type taskplus.tem | more
echo ######## ====================================================
echo ######## The resulting taskplus.tem file has been typed
echo ######## to the screen through the more program.
echo ######## .
echo ######## The new file is now ready for you to edit the
echo ######## TBD data lines.
echo ######## ====================================================
pause
*
text example 57
+------------------------------------------------------------------------+
| |
| If, in the former example, if you wanted to append ONLY to specific |
| records, perhaps with a specific date, use the -j option to limit the |
| appending action to "hits" only. |
| |
| For example: |
| |
| echo FINISH_DATE-: 961210 > zzapfile |
| and |
| dg -a "PRIORITY----: 1" tasks.sam > taskplus.tem |
| |
| The -a option alone indicates that we want all records printed (even |
| with no -l, so that we have an entire updated file) BUT the presence |
| of a searchterm limits the appending action to hits on the searchterm |
| given. |
| |
| We'll pipe the result through "more" so you can see that only the |
| "hit" record (there happens to be only one hit) has been appended. |
| |
+------------------------------------------------------------------------+
*
rem do example 57
cls
dg -ekp "text example 57" samples.dat
echo ######## .
echo ######## .
pause
echo FINISH_DATE-: 961210 > zzapfile
dg -a "PRIORITY----: 1" tasks.sam > taskplus.tem
type taskplus.tem | more
echo ######## ====================================================
echo ######## The resulting taskplus.tem file has been typed
echo ######## to the screen. Only one record was appended.
echo ######## .
echo ######## The new file could now be further appended for
echo ######## other search terms and append data.
echo ######## ====================================================
pause
*
text example 58
+------------------------------------------------------------------------+
| In the two previous examples, the -a option printed all records. This |
| usage is appropriate when just creating updates to a master file. The |
| result can then be copied to replace the master. |
| |
| If we wanted only an EXTRACT holding the hit records, with the append |
| action done, use -j to modify the behavior of the -a option: |
| |
| dg -aj "PRIORITY----: 1" tasks.sam > taskplus.tem |
| |
| The -a option with a -j modifier, indicates that we want ONLY |
| the records with hits to be printed. |
| |
+------------------------------------------------------------------------+
*
rem do example 58
cls
dg -ekp "text example 58" samples.dat
echo ######## .
echo ######## .
pause
echo FINISH_DATE-: 961210 > zzapfile
dg -aj "PRIORITY----: 1" tasks.sam > taskplus.tem
type taskplus.tem
echo ######## ====================================================
echo ######## The resulting taskplus.tem file has only the hit.
echo ######## The file has been typed to the screen.
echo ######## ====================================================
pause
*
text example 59
+------------------------------------------------------------------------+
| |
| A different kind of appending can be done with the -A option. |
| |
| This option appends line 1 of "zzapfile" to the first keyline |
| of a record. |
| |
| For example, we may decide that all our tasks.sam keylines need a tag |
| such as "OST" so that we can mix the tasks.sam records with some |
| other records, yet be able to retrieve these independently. |
| |
| As before, create zzapfile: |
| |
| echo OST > zzapfile |
| |
| Then use: |
| |
| dg -Al tasks.sam > taskplus.tem |
| |
+------------------------------------------------------------------------+
*
rem do example 59
cls
dg -ekp "text example 59" samples.dat
echo ######## .
echo ######## .
pause
echo OST > zzapfile
dg -Al tasks.sam > taskplus.tem
type taskplus.tem
echo ######## ====================================================
echo ######## The resulting taskplus.tem file now has the
echo ######## desired identifier in all keylines.
echo ######## .
echo ######## You may also use the -j option to limit this
echo ######## kind of append action to hits only.
echo ######## ====================================================
pause
*
text example 60
+------------------------------------------------------------------------+
| You may use the (uppercase!) -J option with the -a or -A options to |
| tack on the record number of each record. Use -aJ to add the record |
| number as a final line in the record, or -AJ to tack the record |
| number onto the keyline. The contents of zzapfile, if any, will come |
| in first. If only line numbers are wanted, zzapfile must still |
| exist, but may be null. |
| |
| We'll demo the -AJ case here. First, we'll create a null (EMPTY) |
| zzapfile (UNIX, use: rm zzapfile, then touch zzapfile) |
| |
| @REM >zzapfile |
| |
| Then make the call: |
| |
| dg -AJl tasks.sam > taskplus.tem |
| |
| We'll use "more" this time to allow you to inspect each keyline. |
| |
+------------------------------------------------------------------------+
*
rem do example 60
cls
dg -ekp "text example 60" samples.dat
echo ######## .
echo ######## .
pause
@REM >zzapfile
rem @echo off
rem above is a dos-based touch command
dg -AJl tasks.sam > taskplus.tem
type taskplus.tem | more
echo ######## ====================================================
echo ######## Note the record numbers appended to the keylines.
echo ######## .
echo ######## With a -aJl option, the record numbers would have
echo ######## been appended after the last line of each record.
echo ######## ====================================================
pause
if %1 == dem5 goto end
*
text example 61
+------------------------------------------------------------------------+
| |
| +----------------------------------------+ |
| | DG DEMO PART 6 -- ADVANCED USERS ONLY | |
| +----------------------------------------+ |
| |
| -- Records with labeled lines |
| ---- Finding Extra (dupe) labeled lines (-E) |
| ---- Automating data updates (-B) |
| |
| |
+------------------------------------------------------------------------+
*
rem do example 61
:dem6
@echo off
cls
dg -ekp "text example 61" samples.dat
pause
*
text example 62
+------------------------------------------------------------------------+
| |
| emps.sam is a sample flat file of employees, their language skills, |
| and some simulated personnel data. It's in a partial labeled-line |
| form. Here's an example record: |
| |
| ann marie smith |
| english french chinese |
| ssn: 666-666-666 |
| salary: 666666 |
| hired: 960606 |
| manager: brian adams |
| * |
| etc. |
| |
+------------------------------------------------------------------------+
*
rem do example 62
cls
dg -ekp "text example 62" samples.dat | more
pause
*
text example 63
+------------------------------------------------------------------------+
| |
| We'll use this emps.samp file to demonstrate the -E "Extra" option. |
| An option of -E5 means: report records that have the search term on |
| 5 or more lines. It's like an -M5 option, but an -M5 option is |
| intended for use with 5 different terms, not to look for 5 instances |
| of the same term. |
| |
| To see whether any of our records had more than one use of a line |
| with the term "ssn:" we search with: |
| |
| dg -E ssn: emps.sam |
| |
| The -E option without a numeric defaults to -E2. |
| |
+------------------------------------------------------------------------+
*
rem do example 63
cls
dg -ekp "text example 63" samples.dat | more
pause
cls
dg -E ssn emps.sam
echo ######## ====================================================
echo ######## The ringer case in the records has been found.
echo ######## This search capability has proven more useful than
echo ######## it looks in a number of cases when file records
echo ######## were being inspected.
echo ######## .
echo ######## The use of -E is not limited to labeled-line files.
echo ######## ====================================================
pause
*
text example 64
+------------------------------------------------------------------------+
| |
| Now lets use the emps.sam file to demonstrate the -B option. |
| |
| WARNING: Most users should skip the rest of this demo and never |
| use the -B option. This is a complicated option and of value |
| only rarely. |
| |
| Normally a simple text editor or awk is the way to go when updating |
| simple flat files. But there are cases when the changes or updates |
| wanted can be more easily generated in a batch file, and integrated |
| using dg. |
| |
| This option offers a primitive way to update certain kinds of data |
| files. emps.sam has a one-labeled-field-per-line structure, and that |
| is the only structure supported by the -B option: |
| |
+------------------------------------------------------------------------+
*
rem do example 64
cls
dg -ekp "text example 64" samples.dat | more
pause
*
text example 65
+------------------------------------------------------------------------+
| |
| A sample update file has been prepared, for emps.sam, named |
| empupdat.sam: |
| |
| bill kelly ~salary: 111111 |
| bill kelly ~ssn: 111-111-1111 |
| pete ~salary: 111111 |
| chinese ~manager: Aaron Aaronson |
| |
| The update file is intended to update 2 fields for "bill kelly", one |
| field for "pete" and the "manager" field for all employees with |
| "chinese" as a listed skill. The update file uses 111 and Aa |
| patterns to help you see just where the changes took place when the |
| demo runs. To make an updated file from emps.sam : |
| |
| dg -k2B empupdat.sam emps.sam > emps.tem |
| |
| (See the documentation for an understanding of how the -k option must |
| always be used with the -B option.) |
+------------------------------------------------------------------------+
*
rem do example 65
cls
dg -ekp "text example 65" samples.dat | more
pause
cls
dg -k2B empupdat.sam emps.sam > emps.tem
echo ######## ====================================================
echo ######## The result is in file emps.tem
echo ######## which will now be typed to the screen.
echo ######## .
echo ######## Note the 111 mods for bill kelly
echo ######## and the manager mods for those with chinese skills.
pause
type emps.tem | more
echo ######## ====================================================
echo ######## Note that pete's salary was appended to his
echo ######## record, since it originally had no salary field.
echo ######## ====================================================
echo ######## See the manual for more details about the -B option.
echo ######## ====================================================
pause
if %1 == dem6 goto end
if %1 == all goto end
*
rem do example 65
rem not really an example, but the repeated searchterm is needed.
:hlp
echo ######## Need valid arguments. Use one of the following:
echo ######## go all ...not recommended
echo ######## go dem1
echo ######## go dem2
echo ######## go dem3
echo ######## go dem4
echo ######## go dem5
echo ######## go dem6
echo ######## For section overviews, use:
echo ######## go list
goto finished
:list
dg "DEMO PART" samples.dat > ztem
dg -v finished ztem | more
del ztem
goto finished
:end
echo ######## You have completed the dg examples review, %1
:finished
*